/******************************************************************************/
/* Files to Include                                                           */
/******************************************************************************/

#include <xc.h>            /* HiTech General Includes */
#include <stdint.h>         /* For uint8_t definition */
#include <stdbool.h>        /* For true/false definition */

#include "user.h"

/******************************************************************************/
/* User Functions                                                             */
/******************************************************************************/

/* <Initialize variables in user.h and insert code for user algorithms.> */

void InitApp(void)
{
    /* TODO Initialize User Ports/Peripherals/Project here */


    /* Setup analog functionality and port direction */
    ANSEL  = 0x00;
    ANSELH = 0x04;											/* AN10 SELECT*/

    /* Initialize peripherals */
    PORTA = 00;
    TRISA = 0x0C;
    WPUA  = 0x04;

	PORTB = 0x00;
//	TRISB = 0xF0;
	TRISB = 0x10;
	WPUB  = 0x00;

	LATC = 0x00;
//	TRISC = 0xFF;
	TRISC = 0x00;

	T0CON = (1 << 7) |
		    (1 << 6) |
		    (0 << 5) |
			(0 << 4) |
			(1 << 3) |
			(1 << 0);

	T2CON = (0 << 3)|
			(1 << 2)|
			(2 << 0);

	/* Enable interrupts */
	INTCON = (1 << 7)|
			 (1 << 6)|
			 (1 << 5);
	PIE1   = (1 << 1);
	PIE2   = 0x00;
	IOCA   = 0x00;
}

